package org.ax.service.sys.imple;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.ax.mapper.sys.RoleMapper;
import org.ax.mapper.sys.UserMapper;
import org.ax.pojo.sys.Role;
import org.ax.pojo.sys.User;
import org.ax.service.sys.RoleService;
import org.ax.service.sys.UserService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-23-14:49
 */
@Service
public class IRoleService extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Override
    public Page<Role> findRoleList(Page page) {
        return getBaseMapper().selectPage(page, null);
    }

    @Override
    public boolean addRole(Role role) {
        return getBaseMapper().insert(role)>0;
    }

    @Override
    public boolean updateRole(Role role) {
        return getBaseMapper().updateById(role)>0;
    }

    @Override
    public boolean deletesRole(String[] ids) {
        return getBaseMapper().deleteBatchIds(Arrays.asList(ids))>0;
    }

    @Override
    public Role toRoleId(String id) {
        return getBaseMapper().selectById(id);
    }

    @Override
    public List<Role> availableRole() {
        QueryWrapper<Role> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("available", "1");
        return getBaseMapper().selectList(queryWrapper);
    }
}
